<template >
    <div class="bigcon" >
        <!-- 头部 -->
        <div class="favorites-head">
            <van-nav-bar title="收藏夹" left-text="" :right-text="DutDelete" left-arrow @click-left="onClickLeft"
                @click-right="onClickRight" />
        </div>
            
        <van-tabs v-model:active="activeName" background="#eae9e5" line-color='#000' title-active-color="#c1ab96">
            <van-checkbox-group v-model="checked">
                <div class="favorites-goods">
                    <van-tab title="全部" name="a">
                            <div class="aa" v-for="(item,index) in FavoritesData" :key="index" >
                                    <van-checkbox v-show="ShowDelete" :name="index" @click="aaa" />
                                <van-card :price="item.age " :desc="item.miaos" title="商品标题"
                                    :thumb="item.img">
                                    <template #tags>
                                        <van-tag plain type="danger">{{item.yhj}}</van-tag>
                                        <van-tag plain type="danger">{{item.linju}}</van-tag>
                                    </template>
                                    <template #footer>
                                        <van-button size="mini">找相似</van-button>
                                    </template>
                                </van-card>
                            </div>
                   
                   
                    </van-tab>
                    <van-tab title="降价中" name="b">
                        <div class="aa">
                        
                            <van-checkbox v-show="ShowDelete" name="1" />
                      
                        <van-card price="2.00" desc="200人已收藏" title="商品标题"
                            thumb="https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg">
                            <template #tags>
                                <van-tag plain type="danger">满300减30</van-tag>
                                <van-tag plain type="danger">店铺领卷</van-tag>
                            </template>
                            <template #footer>
                                <van-button size="mini">找相似</van-button>
                            </template>
                        </van-card>
                    </div>
                    </van-tab>
                    <van-tab title="低库存" name="c">
                        <div class="aa">
                        
                            <van-checkbox v-show="ShowDelete" name="1" />
                      
                        <van-card price="2.00" desc="200人已收藏" title="商品标题"
                            thumb="https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg">
                            <template #tags>
                                <van-tag plain type="danger">满300减30</van-tag>
                                <van-tag plain type="danger">店铺领卷</van-tag>
                            </template>
                            <template #footer>
                                <van-button size="mini">找相似</van-button>
                            </template>
                        </van-card>
                    </div>
                    </van-tab>
                    <van-tab title="已失效" name="d">
                        <div class="aa">
                        
                            <van-checkbox v-show="ShowDelete" name="1" />
                      
                        <van-card price="2.00" desc="200人已收藏" title="商品标题"
                            thumb="https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg">
                            <template #tags>
                                <van-tag plain type="danger">满300减30</van-tag>
                                <van-tag plain type="danger">店铺领卷</van-tag>
                            </template>
                            <template #footer>
                                <van-button size="mini">找相似</van-button>
                            </template>
                        </van-card>
                    </div>
                    </van-tab>
                </div>
            </van-checkbox-group>
        

        </van-tabs>

    </div>

</template>
<script setup lang="ts" >
import { onMounted, ref } from 'vue'
import {favorites} from '@/api/my1.ts'
const onClickLeft = () => history.back();
const onClickRight = () => {
    if(DutDelete.value=="删除"){
        DutDelete.value="编辑"
        ShowDelete.value=false
        checked.value.forEach(i=>{
            FavoritesData.value.splice(i,1)
        })
        checked.value=[]

    }else{
        DutDelete.value="删除"
        ShowDelete.value=true

    }
}
let DutDelete=ref("编辑")
let ShowDelete=ref(false)
const activeName = ref('a');
const active = ref(0);
const checked = ref([]);
let aaa=function(){
    console.log(checked.value   );
    
}
//获取后台数据
let FavoritesData=ref([])
onMounted(()=>{
    favorites()
        .then(res=>{
            console.log(res);
            FavoritesData.value=res.data.data
            
        })
})
</script>
<style>
.favorites-head {
    width: 100%;
    background: #eae9e5;
    height: 10vw;
    position: fixed;
    top: 0;
    z-index: 10;

}

 .bigcon .van-nav-bar__title {
    font-weight: 800 !important;
}
 .bigcon .van-tabs__wrap{
    width: 100%;
    height: 10vw;
    top: 10vw;
    position: fixed !important ;
    z-index: 10;
}
 .bigcon .van-nav-bar__content {
    background: #eae9e5 !important;
    border: 0;
}

 .bigcon .van-icon {
    color: #c5a28f !important;
}

 .bigcon .van-nav-bar__text {
    color: #333333 !important;
    font-size: 1vw !important;
}

.favorites-goods {
    padding: 4vw;
    margin-top: 20vw;
}

 .bigcon .van-card {
    border-radius: 2vw;
    border: 1px solid #dedede;
    box-shadow:.5vw 1vw 2vw .8vw rgb(236, 230, 230);


    background: #fff;
    flex: 1;
    margin-left: 2vw;
}

.aa {
    display: flex;

}
</style>